linux使用crontab命令定时重启服务器 | 您所在的位置:网站首页 › crontab 关闭 › linux使用crontab命令定时重启服务器 |
服务器不重启的情况下定时自动重启 apache 及 mysql 服务,其实也大同小异。具 体步骤如下:
一、每天的 12 点及 16 点重启 apache 及 mysql 服务
[root@www bin]# cd /opt/ [root@www opt]# vim reboot.txt 在 reboot.txt.txt 文件中输入下面的内容后保存
0 12 * * * service httpd restart 0 12 * * * service mysqld restart 0 16 * * * service httpd restart 0 16 * * * service mysqld restart
二、把新建的文件加入到 cron 服务中
[root@www opt]# crontab reboot.txt [root@www opt]# crontab -l 0 12 * * * service httpd restart 0 12 * * * service mysqld restart 0 16 * * * service httpd restart 0 16 * * * service mysqld restart
三、重启 cron 服务
[root@www opt]# /sbin/service crond restart
======================================= 补充说明:
cron 是一个 linux 下的定时执行工具,可以在无需人工干预的情况下运行作业。由 于 Cron 是 Linux 的内置服务,但它不自动起来,可以用以下的方法启动、关闭这个 服务:
/sbin/service crond start // 启动服务
|
CopyRight 2018-2019 实验室设备网 版权所有 |